package com.bestcem.xm.qdes.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bestcem.xm.component.mybatis.service.IXmService;
import com.bestcem.xm.qdes.controller.param.GetFolderParam;
import com.bestcem.xm.qdes.controller.param.ProjectFolderIdParam;
import com.bestcem.xm.qdes.controller.param.ProjectFolderParam;
import com.bestcem.xm.qdes.controller.param.ProjectFolderUpdateParam;
import com.bestcem.xm.qdes.controller.vo.FolderVo;
import com.bestcem.xm.qdes.entity.QdesProjectFolder;

import java.util.List;

public interface QdesProjectFolderService extends IXmService<QdesProjectFolder> {

    default void foldersTree(JSONArray list, List<String> ids) {
        for (int i = 0; i < list.size(); i++) {
            JSONObject item = list.getJSONObject(i);
            String id = item.getString("id");
            ids.add(id);
            JSONArray childrens = item.getJSONArray("children");
            foldersTree(childrens, ids);
        }
    }

    /**
     * 获取文件夹
     *
     * @param getFolderParam getFolderParam
     */
    FolderVo getFoldertree(GetFolderParam getFolderParam);

    /**
     * 创建文件夹
     *
     * @param param param
     */
    void createFoldertree(ProjectFolderParam param);

    /**
     * 修改文件夹名称
     *
     * @param param param
     */
    void updateFoldertree(ProjectFolderUpdateParam param);

    /**
     * 删除文件夹
     *
     * @param param param
     */
    void deleteFoldertree(ProjectFolderIdParam param);
}
